﻿using System;
using System.Collections.Generic;
using BrightcoveAPI;
using System.Text;

namespace Test
{
    class Program
    {       
        static void Main(string[] args)
        {     
            //First, you MUST configure your read and write tokens
            BCAPI.Configuration.ReadToken = "1234567890";
            BCAPI.Configuration.WriteToken = "0987654321";

            //Result variable for array of videos, implemented as a Dictionary for fast lookup by ID
            Dictionary<long, BCVideo> videos;

            //Result variable for a single video
            BCVideo video;

            //Test the FindAllVideos API Call
            videos = BCAPI.FindAllVideos(-1, -1, BCSortByType.CREATION_DATE, BCSortOrderType.ASC, null, true);
            foreach (BCVideo v in videos.Values)
            {
                Console.WriteLine("FindAllVideos() - Found video: " + v.name);
            }

            //Test the FindByID API Call with an existing video. 
            //You need to replace the video id with an asset id defined in your account!
            video = BCAPI.FindVideoById(1909882514);
            if (video != null)
            {
                Console.WriteLine("FindByID() - Found video: " + video.name);
            }
            else
            {
                Console.WriteLine("FindByID() for existing video returned null. Wrong id?");
            }

            //Test the FindByID API Call with an non-existing video (returns a null object)
            video = BCAPI.FindVideoById(9999999999, null);
            if (video == null)
            {
                Console.WriteLine("FindByID() for unexisting video returned null");
            }
            else
            {
                Console.WriteLine("FindByID() - A Miracle! - Found video: " + video.name);
            }

            //Test the FindRelatedVideos API Call
            //You need to replace the video id with an asset id defined in your account!
            videos = BCAPI.FindRelatedVideos(1631314667, -1, -1, null, true);
            foreach (BCVideo v in videos.Values)
            {
                Console.WriteLine("FindRelatedVideos() - Found video: " + v.name);
            }

            //Test the FindVideosByIds API Call
            List<long> ids = new List<long>();
            ids.Add(1459158571);
            ids.Add(1631314667);
            videos = BCAPI.FindVideosByIds(ids, null);
            foreach (BCVideo v in videos.Values)
            {
                Console.WriteLine("FindVideosByIds() - Found video: " + v.name);
            }         
        }
    }
}
